home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 June: Reference Library / Dev.CD Jun 96 RL / Dev.CD Jun 96 RL.toast / Technical Documentation / develop / develop Issue 24 / develop Issue 24 code / Scriptable Database 1.0a15 / Blue / Futures.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-02-19  |  2.6 KB  |  92 lines  |  [TEXT/CWIE]

  1. /*
  2.     File:        Futures.h
  3.  
  4.     Contains:    Header file for futures
  5.  
  6.     Written by:    Andy Nicholas, Greg Anderson, Tom Conrad, Chris Bingham, Georgiann Puckett, John Thompson-Rohrlich, Max McFarland
  7.  
  8.     Copyright:    © 1994 by Apple Computer, Inc., all rights reserved.
  9.  
  10.          <2>     7/21/94    andy    
  11.  
  12. */
  13.  
  14. #ifndef Futures_h
  15. #define Futures_h
  16.  
  17. #ifndef __MIXEDMODE__
  18. #include <MixedMode.h>
  19. #endif
  20. #ifndef __APPLEEVENTS__
  21. #include <AppleEvents.h>
  22. #endif
  23. #ifndef __THREADS__
  24. #include <Threads.h>
  25. #endif
  26.  
  27. //
  28. // Constants
  29. //
  30. #define kNoMaximumWait                    (0x7FFFFFFF)
  31.  
  32. //
  33. // Keyword keyAEResetTimerFrequency specifies
  34. // approximately how frequently (in ticks) the 
  35. // client would like the server to call AEResetTimer.
  36. // This value is advisory only, and is typically
  37. // one-half of the timeout value.
  38. //
  39. #define keyAEResetTimerFrequencyAttr     'resf'
  40.  
  41. //
  42. // This is how frequently a server should call
  43. // AEResetTimer if the AppleEvent message doesn't
  44. // contain a 'reset timer frequency' attribute
  45. //
  46. #define kDefaultResetTimerFrequency        30
  47.  
  48. //
  49. // Values for InitFutures
  50. //
  51. #define kNoSpecialFutureFeatures        0
  52. #define kSpawnHousekeepingThread        0x0001
  53. #define kInstallAsyncPreDispatchHandler    0x0002
  54. #define kAllSpecialFutureFeatures        (kSpawnHousekeepingThread | kInstallAsyncPreDispatchHandler)
  55.  
  56. typedef pascal OSErr (*ThreadCreateProcPtr)(ThreadEntryProcPtr threadEntry, void* threadParam, long handlerRefCon, ThreadID* threadMade);
  57.  
  58. #ifdef __cplusplus
  59. extern "C" {
  60. #endif
  61.  
  62. //
  63. // Prototypes for Future functions
  64. //
  65. OSErr InitFutures(ThreadCreateProcPtr threadCreateProc, long initFuturesFlags);
  66. void BlockUntilReal(AppleEvent* reply);
  67. Boolean ReplyArrived(AppleEvent* reply);
  68. void SetReplyTimeoutValue(AppleEvent* reply, long timeoutValue, long maxWaitTime);
  69. void IdleFutures();
  70. OSErr AskForFuture(AppleEvent* ae, AppleEvent* reply, long timeoutValue, long maxWaitTime, AESendMode sendMode, AESendPriority sendPriority);
  71. long GetResetTimerFrequency(AppleEvent* ae);
  72. OSErr ResetTimerIfNecessary(const AppleEvent* reply, unsigned long& lastReset, long resetFrequency);
  73.  
  74. #ifdef __cplusplus
  75. }
  76.  
  77. //
  78. // Default parameters: for use with C++ compilers
  79. //
  80. inline OSErr InitFutures(ThreadCreateProcPtr threadCreateProc = nil /* kAllSpecialFutureFeatures */) { return InitFutures(threadCreateProc, kAllSpecialFutureFeatures); }
  81. inline OSErr AskForFuture(AppleEvent* ae, AppleEvent* reply, long timeoutValue = kAEDefaultTimeout, long maxWaitTime = kNoMaximumWait, AESendMode sendMode = 0 /* kAENormalPriority */) { return AskForFuture(ae, reply, timeoutValue, maxWaitTime, sendMode, kAENormalPriority); }
  82.  
  83. #endif
  84.  
  85. //
  86. // Backwards compatability API
  87. //
  88. #define IsFuture(reply)        (!ReplyArrived(reply))
  89.  
  90. #endif // Futures_h
  91.  
  92.